#ifndef LAB_H_
#define LAB_H_

#include "eye.hpp"
#include "stuff.hpp"

#include <map>
#include <vector>
#include <string>
#include <GL/glu.h>

using namespace std;

#define F_OBJECTS            (1 << 0)
#define F_INTERSECT          (1 << 1)
#define F_GRID               (1 << 2)
#define F_COLLISION_MODELS   (1 << 3)

#define F_ALL        (~0)

enum CamControlMode { CCM_NONE = 0, CCM_ROTATE, CCM_MOVE };

class VisVector {
public:
    float r, g, b;
    Vector p1, p2;

    static VisVector from_origin(float r, float g, float b, Vector o, Vector v);
};

class VisSet {
public:
    string name;
    vector<VisVector> vectors;

    void clear() { vectors.clear(); }
    void add(VisVector vv) { vectors.push_back(vv); }
};


class Ground0;

class Lab : public BasicScene, public Controller {
private:
    friend class Ground0;

    vector<VisSet> vis_stack;
    int vis_focus;

    int        filter;
    bool       collision;

    float      cam_r, cam_heading, cam_elevation;
    int        cam_control_mode;

    GLUquadricObj *q_sphere;
    
    void       update_cam_pos();
    void       draw_grid();
    void       draw_debug();
    void       draw_cm(Stuff &cm);
    void       lab_action(int n);

    bool       test();

public:
    Stuff                  *s1, *s2;
    int mode;
    bool paused;

    Lab();
    virtual ~Lab();
    void init();

    virtual void           tick(unsigned int ms);
    virtual void           render();

    virtual void  on_keydown(struct SDL_KeyboardEvent *ev);
    virtual void  on_keyup(struct SDL_KeyboardEvent *ev);
    virtual void  on_mouse_down(struct SDL_MouseButtonEvent *ev);
    virtual void  on_mouse_up(struct SDL_MouseButtonEvent *ev);
};

#endif


